package com.beijiteshop.shop.base

import android.content.Context
import android.os.Bundle
import android.util.Log
import com.beijiteshop.libcommon.base.fragment.BaseLazyFragment
import com.beijiteshop.libcommon.event.LoginEvent
import com.beijiteshop.libcommon.utils.EventUtil
import com.beijiteshop.shop.app.PageIndex
import com.beijiteshop.shop.ui.login.LoginActivity
import com.blankj.utilcode.util.LogUtils

/**
 * @Author LiaoZhongKai
 * @Date 2021/3/8 14:15
 * @Description 封装了单Activity多Fragment场景下,需要的一些操作
 */
abstract class BaseContainerFragment(layoutId: Int) : BaseLazyFragment(layoutId) {

    private var mIFragmentContainerListener: IFragmentContainerListener? = null
    private lateinit var mContext: Context

    override fun onAttach(context: Context) {
        super.onAttach(context)
        mContext = context
        mIFragmentContainerListener = context as? IFragmentContainerListener
    }

    /**
     * 启动Activity
     * @param fragment索引 @see PageIndex
     */
    fun startActivity(fragment: Int,bundle: Bundle? = null){
        FragmentContainerActivity.start(mContext,fragment, bundle)
    }

    /**
     * 关闭当前fragment
     */
    fun close(){
        mIFragmentContainerListener?.onBack()
    }
}